<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const registerServiceWorker = async () => {
            if ("serviceWorker" in navigator) {
                try {
                    const registration = await navigator.serviceWorker.register("service-worker.js", {});
                    if (registration.installing) {
                        console.log("正在安装 Service worker");
                    } else if (registration.waiting) {
                        console.log("已安装 Service worker installed");
                    } else if (registration.active) {
                        console.log("激活 Service worker");
                    }
                } catch (error) {
                    console.error(`注册失败：${error}`);
                }
            }
        };

        registerServiceWorker();
    </script>
</body>

</html>